updating oE new_from_string

new_from_string

include map.e 
namespace map 
public function new_from_string(sequence kv_string) 

converts a set of key:value pairs contained in a string to a map.

Parameters:
  1. kv_string : A string containing any number of lines that have the format KEY=VALUE. These are loaded into a new map which is then returned by this function.
Returns:

A map, containing the data from kv_string

Comments:

This function actually calls keyvalues to convert the string to key-value pairs, which are then used to create the map.

Example 1:

Given that a file called "xyz.config" contains the lines ...

application = Euphoria, 
version     = 4.0, 
genre       = "programming language", 
crc         = 4F71AE10 

map m1 = new_from_string( read_file("xyz.config", TEXT_MODE)) 
 
printf(1, "%s\n", {map:get(m1, "application")}) --> "Euphoria" 
printf(1, "%s\n", {map:get(m1, "genre")})       --> "programming language" 
printf(1, "%s\n", {map:get(m1, "version")})     --> "4.0" 
printf(1, "%s\n", {map:get(m1, "crc")})         --> "4F71AE10"   
Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu